//
//  SecController.m
//  OpenEyes
//
//  Created by dlios on 15/9/11.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "SecController.h"
#import "LazyFadeInView.h"
#import "PlayViewController.h"
@interface SecController ()<requestDelegate>
@property (strong, nonatomic) LazyFadeInView *fadeInView;
@property (strong ,nonatomic) NSTimer *mytime;


@end

@implementation SecController

-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
   
    //开启定时器
    [self.mytime setFireDate:[NSDate distantPast]];
}


-(void)viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = NO;
    
    
    //关闭定时器
    [self.mytime setFireDate:[NSDate distantFuture]];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"音乐详情";
    self.secArray = [NSMutableArray array];
    // Do any additional setup after loading the view.
   
    [self setview ];
    [self Getdata];
}
-(void)setview{
    //添加一个返回按钮
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"fanhui-3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(left)];
    
    self.music =[[MusicView alloc]initWithFrame:self.view.frame];
    
    
    [self.view addSubview: self.music];
    
    //给图片一个手势
    UITapGestureRecognizer *single = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click)];
    
    single.numberOfTapsRequired = 1;
    
    [self.music.clearView addGestureRecognizer:single];
    
    
   // 菊花
    self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    self.HUD.removeFromSuperViewOnHide = YES;
    self.HUD.labelText = @"loading.....";
    [self.view addSubview:self.HUD];
    self.HUD.mode = MBProgressHUDModeIndeterminate;

    //定时器
   self.mytime = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(Timer) userInfo:nil repeats:YES];
    
    
    
    
}
-(void)add{
    
}
//计时器方法
-(void)Timer{
    [UIView animateWithDuration:10 animations:^{
        self.music.image.transform = CGAffineTransformScale(self.music.image.transform, 1.2, 1.2);
        
    } completion:^(BOOL finished) {
        
       [UIView animateWithDuration:10 animations:^{
           self.music.image.transform = CGAffineTransformScale(self.music.image.transform,1/1.2, 1/1.2);
       } completion:^(BOOL finished) {
           
//           NSLog(@"123");
           return ;
           
       }];
    }];
    
}
-(void)left{
    [self.navigationController popViewControllerAnimated:YES];
}


-(void)Getdata{
    
 
    [[HttpRequest httpRequestHandle]loadRequestWithUrl:@"http://lab.daigj.com/api/ios/hm/detail" method:@"POST" pramar:[NSString stringWithFormat:@"version=1.0.2&token=ARk6MCqumCVjvSM1yEuacwOqi%%2FYAFLJxeKE%%3D&id=%@",self.mo._id]];
    [HttpRequest httpRequestHandle].delegate = self ;
}


-(void)requestData:(id)data
{
    [self.HUD setHidden:YES];
    NSDictionary *dicdata = data [@"data"][@"detail"];
    [self.HUD setHidden:YES];
    MusicModel * mo= [[MusicModel alloc]init];
    [mo setValuesForKeysWithDictionary:dicdata];
    self.url =[dicdata objectForKey:@"playUrl"];
 
    [self.music add:mo];
   
}


-(void)click
{
    NSLog(@"");
    PlayViewController * play =[[PlayViewController alloc]init];
    play.plurl = self.url;
    [self.navigationController pushViewController:play animated:YES];
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
